<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>待生产订单</title>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">

    <script src="/js/axios.min.js"></script>
    <script src="/js/vue.js"></script>
    <script src="/js/qs.min.js"></script>
    <script src="/js/jquery.js"></script>

    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>
<body>
<h2>待生产订单</h2>
<div id="app">
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="交接单查询">
            <el-input v-model="formInline.id" placeholder="请输入订单号"></el-input>
        </el-form-item>
        <el-form-item label="生产状态">
            <el-radio v-model="formInline.status" label="3">已完成</el-radio>
            <el-radio v-model="formInline.status" label="2">未生产</el-radio>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="onSubmit">查询</el-button>
        </el-form-item>
    </el-form>

    <el-table style="width: 100%"
              :data="Page.data"
              ref="Table"
              @selection-change=""
              row-key="id">
        <el-table-column label="序号">
            <template slot-scope="scope">
                <span>{{ scope.row.order2s.id }}</span>
            </template>
        </el-table-column>
        <el-table-column label="订单编号">
            <template slot-scope="scope">
                <span>{{ scope.row.order2s.orderId }}</span>
            </template>
        </el-table-column>
        <el-table-column label="产品名称">
            <template slot-scope="scope">
                <span>{{ scope.row.products.pname }}</span>
            </template>
        </el-table-column>
        <el-table-column label="产品型号">
            <template slot-scope="scope">
                <span>{{ scope.row.products.penterprise }}</span>
            </template>
        </el-table-column>
        <el-table-column label="产品数量">
            <template slot-scope="scope">
                <span>{{ scope.row.order2s.number }}</span>
            </template>
        </el-table-column>
        <el-table-column label="生产产线">
            <template slot-scope="scope">
                <span>{{ scope.row.productionLines.productionName }}</span>
            </template>
        </el-table-column>
        <el-table-column label="使用打印机">
            <template slot-scope="scope">
                <span>{{ scope.row.lasers.lPrinter }}</span>
            </template>
        </el-table-column>
        <el-table-column label="生产时间">
            <template slot-scope="scope">
                <span>{{ scope.row.order2s.productTime }}</span>
            </template>
        </el-table-column>
        <el-table-column label="生产状态(2.未生产 3.已完成)">
            <template slot-scope="scope">
                <span style="color: red">{{ scope.row.order2s.productStatus }}</span>
            </template>
        </el-table-column>
        <el-table-column label="备注">
            <template slot-scope="scope">
                <span>{{ scope.row.order2s.remark }}</span>
            </template>
        </el-table-column>
        <el-table-column label="操作">
            <template slot-scope="scope">
                <el-button
                        size="small"
                        type="success"
                        @click="handleEdit(scope.$index, scope.row)"
                        :disabled="scope.row.order2s.productStatus == '3'"
                >加入到激光码生成列表</el-button>
            </template>
        </el-table-column>
    </el-table>
    <div class="block" style="margin-top: 10px;">
        <span class="demonstration">跳转</span>
        <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="current"
                :page-sizes="pageSizes"
                :page-size="pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="Page.count">
        </el-pagination>
    </div>
</div>
</body>
<script>
    new Vue({
        el:"#app",
        data(){
            return{
                //分页数据
                Page:[],
                // 当前页数
                current:1,
                // 每页的数据
                pageSizes:[5,10,20,50],
                // 当前每页的数据
                pageSize:5,
                // 分页背景
                back: true,
                //当前选中的行
                current0:[],
                formInline:{
                    id:"",status:""
                }
            }
        },
        methods: {
            // 加载表单数据
            loadPage:function(){
                axios.get("/Order2ToBeProduced?current="+this.current+"&PAGE_SIZE="+this.pageSize+"&orderId="+this.formInline.id+"&status="+this.formInline.status)
                    .then(res=>{
                        this.Page = res.data;
                    });
            },
            handleSizeChange(val) {
                this.pageSize = val;
                this.loadPage();
            },
            handleCurrentChange(val) {
                this.current = val;
                this.loadPage();
            },
            handleEdit(index, row){
                axios.put("/Order2ToBeProduced/"+row.order2s.id)
                    .then(res=>{
                        if(res.data === "ok"){
                            this.loadPage();
                            this.$message("加入成功!");
                        }
                    });
            },
            onSubmit(){
                axios.get("/Order2ToBeProduced?current="+this.current+"&PAGE_SIZE="+this.pageSize+"&orderId="+this.formInline.id+"&status="+this.formInline.status)
                    .then(res=>{
                        this.Page = res.data;
                    });
            },

        },

        mounted() {
            this.loadPage();
        }

    })
</script>
</html>